home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- ** **
- ** Module: Error_Lib.c **
- ** **
- ** **
- ** Purpose: **
- ** **
- ** **
- ** **
- ** Copyright (C) 1992-1994 Apple Computer, Inc. All rights reserved. **
- ** **
- ** **
- ** Change Log: **
- ** **
- ** **
- *****************************************************************************/
- #include <stdio.h>
-
- #include "QD3D.h"
- #include "QD3DErrors.h"
-
- #include "Error_Lib.h"
- #include "Error_MesgLib.h"
-
- FILE *gErrorFile = NULL;
-
- static void ErrorHandler(
- TQ3Error firstError,
- TQ3Error lastError,
- long reference);
-
- static void WarningHandler(
- TQ3Warning firstWarning,
- TQ3Warning lastWarning,
- long reference);
-
- static void NoticeHandler(
- TQ3Notice firstNotice,
- TQ3Notice lastNotice,
- long reference);
-
- void InstallDefaultErrorHandler(
- void)
- {
- if (gErrorFile == NULL)
- gErrorFile = fopen("error.output","w+");
-
- Q3Error_Register(ErrorHandler, (long) gErrorFile);
- }
-
-
- void InstallDefaultWarningHandler(
- void)
- {
- if (gErrorFile == NULL)
- gErrorFile = fopen("error.output","w+");
-
- Q3Warning_Register(WarningHandler, (long) gErrorFile);
- }
-
-
- void InstallDefaultNoticeHandler(
- void)
- {
- if (gErrorFile == NULL)
- gErrorFile = fopen("error.output","w+");
-
- Q3Notice_Register(NoticeHandler, (long) gErrorFile);
- }
-
- static void ErrorHandler(
- TQ3Error firstError,
- TQ3Error lastError,
- long reference)
- {
- char buf[512];
- TQ3Error dummyError;
-
- sprintf(buf, "First ERROR %d:%s\n", firstError, getErrorString(firstError));
- if (lastError != kQ3ErrorNone)
- sprintf(buf, "\tLast ERROR %d:%s\n", lastError, getErrorString(lastError));
-
- fputs(buf,stdout);
- if (reference != NULL)
- fputs(buf, (FILE *) reference);
-
- /* This clears the sticky error */
- (void) Q3Error_Get(&dummyError);
- }
-
-
- static void WarningHandler(
- TQ3Warning firstWarning,
- TQ3Warning lastWarning,
- long reference)
- {
- char buf[512];
-
- sprintf(buf, "First WARNING %d:%s\n", firstWarning, getWarningString(firstWarning));
- if (lastWarning != kQ3WarningNone)
- sprintf(buf, "\tLast WARNING %d:%s\n", lastWarning, getWarningString(lastWarning));
-
- fputs(buf,stdout);
- if (reference != NULL)
- fputs(buf, (FILE *) reference);
- }
-
- static void NoticeHandler(
- TQ3Notice firstNotice,
- TQ3Notice lastNotice,
- long reference)
- {
- char buf[512];
-
- sprintf(buf, "First NOTICE %d:%s\n", firstNotice, getNoticeString(firstNotice));
- if (lastNotice != kQ3NoticeNone)
- sprintf(buf, "\tLast NOTICE %d:%s\n", lastNotice, getNoticeString(lastNotice));
-
- fputs(buf,stdout);
- if (reference != NULL)
- fputs(buf, (FILE *) reference);
- }
-